const { override, addWebpackAlias, addDecoratorsLegacy, addPostcssPlugins, adjustStyleLoaders } = require('customize-cra')
const path = require('path')
const px2rem = require('postcss-px2rem')

module.exports = override(
    addWebpackAlias({
        "@": path.resolve(__dirname, 'src')
    }),
    addDecoratorsLegacy(),
    addPostcssPlugins([
        px2rem({ remUnit: 75 })
    ]),
    adjustStyleLoaders(rule => {
        if (rule.test.toString().includes('scss')) {
            rule.use.push({
                loader: require.resolve('sass-resources-loader'),
                options: {
                    resources: './src/scss/index.scss'
                }
            })
        }
    })
)
